package cn.yi.boot.mq.rocketmq.message;

import cn.yi.boot.mq.coder.MessageEncoder;
import com.alibaba.rocketmq.common.message.Message;
import lombok.Data;

@Data
public abstract class AbstractMessage<T> {

    private Message message;

    private T data;

    private MessageEncoder<T> encoder;

    public AbstractMessage(String  topic,String tag,String key,T data,MessageEncoder<T> encoder){
        this.data = data;
        this.encoder = encoder;
        this.message = new Message(topic,tag,key,encoder.encode(data));
    }


    public String getTopic(){
        return message.getTopic();
    }
    public String getKey(){
        return message.getKeys();
    }
    public String getTag(){
        return message.getTags();
    }
    public int getFlag(){
        return message.getFlag();
    }
}
